#include "gwyshangniankaohe_15.h"
#include "ui_gwyshangniankaohe_15.h"


#include<QtSql>
#include<QtGui>
#include <QCoreApplication>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlTableModel>
#include <QSqlError>

#include <QLineEdit>
#include <QString>
#include <QStringList>
#include <QFile>
#include <QFileDialog>
#include <QTextEdit>
#include <QTextStream>
#include <QTableWidget>
#include <QXmlStreamWriter>

gwyshangniankaohe_15::gwyshangniankaohe_15(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::gwyshangniankaohe_15)
{
    ui->setupUi(this);
     QSqlQuery query;

     //合计
     query.exec("SELECT COUNT(1) FROM CadreInfo ");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(0,1,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM CadreInfo WHERE RankID='111'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(1,1,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM CadreInfo WHERE RankID='112'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(2,1,new QTableWidgetItem(text ));

     }

     query.exec("SELECT COUNT(1) FROM CadreInfo WHERE RankID='121'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(3,1,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM CadreInfo WHERE RankID='122'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(4,1,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM CadreInfo WHERE  RankID='131'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(5,1,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM CadreInfo WHERE  RankID='132'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(6,1,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM CadreInfo WHERE RankID='141'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(7,1,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM CadreInfo WHERE  RankID='142'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(8,1,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM CadreInfo WHERE  RankID='150'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(9,1,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM CadreInfo WHERE  RankID='160'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(10,1,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM CadreInfo WHERE  RankID='199'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(11,1,new QTableWidgetItem(text ));

     }

     //优秀
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE  Check.IDNum=CadreInfo.IDNum and CheckResult='优秀'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(0,2,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='优秀' and RankID='111'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(1,2,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='优秀' and RankID='112'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(2,2,new QTableWidgetItem(text ));

     }

     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='优秀' and RankID='121'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(3,2,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='优秀' and RankID='122'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(4,2,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='优秀' and  RankID='131'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(5,2,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='优秀' and RankID='132'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(6,2,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='优秀' and RankID='141'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(7,2,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM`Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='优秀' and RankID='142'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(8,2,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM`Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='优秀' and  RankID='150'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(9,2,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM`Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='优秀' and RankID='160'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(10,2,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM`Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='优秀' and  RankID='199'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(11,2,new QTableWidgetItem(text ));

     }

     //称职
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE  Check.IDNum=CadreInfo.IDNum and CheckResult='称职'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(0,3,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='称职' and RankID='111'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(1,3,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='称职' and RankID='112'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(2,3,new QTableWidgetItem(text ));

     }

     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='称职' and RankID='121'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(3,3,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='称职' and RankID='122'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(4,3,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='称职' and  RankID='131'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(5,3,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='称职' and RankID='132'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(6,3,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='称职' and RankID='141'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(7,3,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM`Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='称职' and RankID='142'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(8,3,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM`Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='称职' and  RankID='150'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(9,3,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM`Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='称职' and RankID='160'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(10,3,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM`Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='称职' and  RankID='199'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(11,3,new QTableWidgetItem(text ));

     }


//不称职
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE  Check.IDNum=CadreInfo.IDNum and CheckResult='不称职'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(0,4,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='不称职' and RankID='111'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(1,4,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='不称职' and RankID='112'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(2,4,new QTableWidgetItem(text ));

     }

     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='不称职' and RankID='121'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(3,4,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='不称职' and RankID='122'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(4,4,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='不称职' and  RankID='131'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(5,4,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='不称职' and RankID='132'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(6,4,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='不称职' and RankID='141'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(7,4,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM`Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='不称职' and RankID='142'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(8,4,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM`Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='不称职' and  RankID='150'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(9,4,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM`Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='不称职' and RankID='160'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(10,4,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM`Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='不称职' and  RankID='199'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(11,4,new QTableWidgetItem(text ));

     }

//基本称职
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE  Check.IDNum=CadreInfo.IDNum and CheckResult='基本称职'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(0,5,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='基本称职' and RankID='111'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(1,5,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='基本称职' and RankID='112'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(2,5,new QTableWidgetItem(text ));

     }

     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='基本称职' and RankID='121'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(3,5,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='基本称职' and RankID='122'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(4,5,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='基本称职' and  RankID='131'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(5,5,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='基本称职' and RankID='132'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(6,5,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='基本称职' and RankID='141'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(7,5,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM`Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='基本称职' and RankID='142'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(8,5,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM`Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='基本称职' and  RankID='150'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(9,5,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM`Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='基本称职' and RankID='160'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(10,5,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM`Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='基本称职' and  RankID='199'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(11,5,new QTableWidgetItem(text ));

     }
     //不称职
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE  Check.IDNum=CadreInfo.IDNum and CheckResult='不称职'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(0,6,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='不称职' and RankID='111'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(1,6,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='不称职' and RankID='112'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(2,6,new QTableWidgetItem(text ));

     }

     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='不称职' and RankID='121'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(3,6,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='不称职' and RankID='122'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(4,6,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='不称职' and  RankID='131'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(5,6,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='不称职' and RankID='132'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(6,6,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='不称职' and RankID='141'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(7,6,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM`Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='不称职' and RankID='142'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(8,6,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM`Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='不称职' and  RankID='150'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(9,6,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM`Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='不称职' and RankID='160'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(10,6,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM`Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckResult='不称职' and  RankID='199'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(11,6,new QTableWidgetItem(text ));

     }


//不记
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE  Check.IDNum=CadreInfo.IDNum and CheckContent='无'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(0,7,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckContent='无' and RankID='111'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(1,7,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckContent='无' and RankID='112'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(2,7,new QTableWidgetItem(text ));

     }

     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckContent='无' and RankID='121'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(3,7,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckContent='无' and RankID='122'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(4,7,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckContent='无' and  RankID='131'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(5,7,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckContent='无' and RankID='132'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(6,7,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM `Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckContent='无' and RankID='141'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(7,7,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM`Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckContent='无' and RankID='142'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(8,7,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM`Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckContent='无' and  RankID='150'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(9,7,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM`Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckContent='无' and RankID='160'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(10,7,new QTableWidgetItem(text ));

     }
     query.exec("SELECT COUNT(1) FROM`Check`,CadreInfo WHERE Check.IDNum=CadreInfo.IDNum and CheckContent='无' and  RankID='199'");
     if(query.next()){
         QString text = query.value(0).toString();
         ui->tableWidget->setItem(11,7,new QTableWidgetItem(text ));

     }








}

gwyshangniankaohe_15::~gwyshangniankaohe_15()
{
    delete ui;
}

void gwyshangniankaohe_15::on_pushButton_clicked()
{
    QString filepath = QFileDialog::getSaveFileName(this, tr("Save as xml"),QString(), "XML files (*.xml);;");
    if (filepath.isEmpty()) {
        return;
    }
    filepath += ".xml";

    QFile file(filepath);
    if (!file.open(QFile::WriteOnly | QIODevice::Text)) {
        return;
    }

    QXmlStreamWriter writer(&file);
    writer.setAutoFormatting(true);
    writer.writeStartDocument();//版本号，默认1.0
    writer.writeStartElement("公务员考核情况");
    int row = ui->tableWidget->rowCount();
    int col = ui->tableWidget->columnCount();
    for(int i = 0; i < row; i++)
    {
        //构造行号
        QString row_tmp = "row";
        QString row_tmp1;
        row_tmp1.setNum(i);
        row_tmp.append(row_tmp1);
        writer.writeStartElement("line");
        for(int j = 0; j < col; j++)
        {
            //构造列号
            QString col_tmp = "col";
            QString col_tmp1;
            col_tmp1.setNum(j);
            col_tmp.append(col_tmp1);
            //合成具体位置信息
            QString loc_tmp;
            loc_tmp.append(row_tmp);
            loc_tmp.append(col_tmp);
            QTableWidgetItem *w = ui->tableWidget->item(i,j);
            QString val = w->text();
            writer.writeTextElement(loc_tmp, val);
        }
        writer.writeEndElement();
    }
    writer.writeEndElement();
    writer.writeEndDocument();
    file.close();
}
